package common.core
{
	public class Tab
	{
		private var m_tab : Object;
		
		public function Tab()
		{
			m_tab = new Object;
		}
		
		public function destory() : void
		{
			m_tab = null;
		}
		
		/**
		 * 添加
		 * @param id
		 * @param target
		 */		
		public function add(id:String,target:*) : void
		{
			m_tab[id] = target;
		}
		
		public function remove(id:String) : void
		{
			delete m_tab[id];
		}
		
		public function find(id:String) : *
		{
			return m_tab[id]; 
		}
		
		public function hasItem(id:String) : Boolean
		{
			if(m_tab.hasOwnProperty(id))
			{
				return true;
			}
			
			return false;
		}
		
		public function change(id:String,target:*) : void
		{
			m_tab[id] =  target;
		}
		
		public function removeAll() : void
		{
			for(var id:String in m_tab)
			{
				delete m_tab[id];
			}
		}
		
		public function toArray(sortyOnType : uint=-1) : Array
		{
			var lst : Array = [];
			
			for each(var obj : * in m_tab)
			{
				lst.push(obj);
			}
			
			if(sortyOnType>=0)
			{
				lst.sortOn(sortyOnType);
			}
			
			return lst;
		}
		
		public function get tab() : Object
		{
			return m_tab;
		}
	}
}